/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vue;

import application.FicheMediaController;
import dao.MediaDAO;
import dao.MediaDAOAuteur;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JTextField;
import media.Media;
import media.Photo;

/**
 *
 * @author Florian Minin & Khémon Beh
 */
public class FicheMediaPhoto extends FicheMediaAbstract {

    protected MediaDAO dao;
    private JTextField txtFieldDate;
    private JTextField txtFieldLieu;

    public FicheMediaPhoto(Photo photo) {
        super(photo);
        initComponentsGenerique();
        initComponents();
    }

    public FicheMediaPhoto() {
        super(new Photo());
        initComponentsGenerique();
        initComponents();
    }

    private void initComponents() {
        JLabel lblDate = new JLabel("Date");
        lblDate.setFont(new Font("Lucida Grande", Font.BOLD, 13));
        lblDate.setBounds(18, 291, 61, 16);
        pnlPrincipal.add(lblDate);

        txtFieldDate = new JTextField();
        txtFieldDate.setBounds(18, 303, 501, 28);
        txtFieldDate.setEditable(false);
        pnlPrincipal.add(txtFieldDate);
        txtFieldDate.setColumns(10);

        JLabel lblLieu = new JLabel("Lieu");
        lblLieu.setFont(new Font("Lucida Grande", Font.BOLD, 13));
        lblLieu.setBounds(18, 330, 61, 16);
        pnlPrincipal.add(lblLieu);

        txtFieldLieu = new JTextField();
        txtFieldLieu.setBounds(18, 343, 501, 28);
        pnlPrincipal.add(txtFieldLieu);
        txtFieldLieu.setColumns(10);

        setToModeConsultation();
    }

    public void abonnementComponents(FicheMediaController ctrl) {
        btnModifier.addActionListener(ctrl);
        btnSauvegarder.addActionListener(ctrl);
    }

    @Override
    public void setToModeModification() {
        super.setToModeModification();
        txtFieldLieu.setEditable(true);
    }

    @Override
    public void setToModeConsultation() {
        super.setToModeConsultation();
        txtFieldLieu.setEditable(false);
    }

    @Override
    public void saveModification() {
        Photo photo = (Photo) media;
        photo.setLieuPriseDeVue(txtFieldLieu.getText());
        photo.setDescription(jtxtValDescription.getText());
        photo.setNote(comboBoxNote.getSelectedIndex());
        this.setTitle("Fiche Photo : " + photo.getNomFichier());
    }

    @Override
    public void chargerMedia(Media media) {
        super.chargerMedia(media);
        Photo photo = (Photo) media;
        txtFieldDate.setText(photo.getDate().toString());
        txtFieldLieu.setText(photo.getLieu());
        setTitle("Fiche Photo : " + media.getNomFichier());
    }

    @Override
    public void associerDAO(MediaDAO dao) {
        this.dao = dao;
    }

    public MediaDAO getDAO() {
        return dao;
    }

    @Override
    public void ouvreGestionAuteur(MediaDAOAuteur dao) {
        //Ne concerne pas les photos
    }
}
